package net.da.core.entity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@NamedQueries({
@NamedQuery (name="OrganizationUser.findOrgUserForLogin",
        query="SELECT orgUser " +
            "FROM OrganisationUserEntity orgUser " +
            "WHERE orgUser.userName = :userName AND " +
            "orgUser.password = :password AND " +
            "orgUser.organisationUnit.name = :organisationUnit")
})

@Entity
@Table(name = "organisation_users")
public class OrganisationUserEntity extends BusinessObjectEntity{

    private String userName;

    private String password;

    @OneToOne
    @JoinColumn(name="organisation_unit_id", nullable=false)
    private OrganisationUnitEntity organisationUnit;

    private String firstName;

    private String lastName;

    public OrganisationUnitEntity getOrganisationUnit() {
        return organisationUnit;
    }

    public void setOrganisationUnit(OrganisationUnitEntity organisationUnit) {
        this.organisationUnit = organisationUnit;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

}
